<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;

class Auditing extends Controller
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        //todo:显示要成为作者的和已经成为作者的
        $data = Db('author_user')->where('status','<','2')->select();
        $black = Db('author_user')->where('status','>','1')->select();
        return view('auditing/list',[
            'title'=>'审批',
            'recycle'=>'黑名单',
            'list'=>$data,
            'black'=>$black,
        ]);
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function change(Request $request)
    {
        //todo:拿到要改状态的id;
        $id = $request->param();
        //todo:去数据库改状态
        $res = Db('author_user')->where('id',$id['id'])->setField('status','1');
        if ($res){
            $this->redirect('admin/Auditing/index');
        }else{
            $this->redirect('admin/Auditing/index');

        }

    }


    public function topass(Request $request)
    {
        //todo:拿到要改状态的id;
        $id = $request->param();
        //todo:去数据库改状态
        $res = Db('author_user')->where('id',$id['id'])->setField('status','1');
        if ($res){
            $this->redirect('admin/Auditing/index');
        }else{
            $this->redirect('admin/Auditing/index');

        }
    }


    public function tolose(Request $request)
    {
        //todo:拿到要改状态的id;
        $id = $request->param();
        //todo:去数据库改状态
        $res = Db('author_user')->where('id',$id['id'])->setField('status','2');
        if ($res){
            $this->redirect('admin/Auditing/index');
        }else{
            $this->redirect('admin/Auditing/index');

        }
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
